package com.example.provider01;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/api")
public class Provider01Controller {

    @GetMapping("/hello")
    public String hello() {
        return "Hello from Service Provider!";
    }

    @GetMapping("/users/{userId}")
    @SentinelResource("testSentinel") //次sentinel生效
    public String getUserById(@PathVariable("userId") Long userId) {
        System.out.println("IM Controller" + new Date());
        return "provider01回复:" + userId;
    }
}